﻿using System;
using UnityEngine;
using Valve.VR;

// Token: 0x02000838 RID: 2104
public class SteamVR_Skybox : MonoBehaviour
{
	// Token: 0x060030A1 RID: 12449 RVA: 0x000FCDEC File Offset: 0x000FAFEC
	public void SetTextureByIndex(int i, Texture t)
	{
		switch (i)
		{
		case 0:
			this.front = t;
			break;
		case 1:
			this.back = t;
			break;
		case 2:
			this.left = t;
			break;
		case 3:
			this.right = t;
			break;
		case 4:
			this.top = t;
			break;
		case 5:
			this.bottom = t;
			break;
		}
	}

	// Token: 0x060030A2 RID: 12450 RVA: 0x000FCE64 File Offset: 0x000FB064
	public Texture GetTextureByIndex(int i)
	{
		switch (i)
		{
		case 0:
			return this.front;
		case 1:
			return this.back;
		case 2:
			return this.left;
		case 3:
			return this.right;
		case 4:
			return this.top;
		case 5:
			return this.bottom;
		default:
			return null;
		}
	}

	// Token: 0x060030A3 RID: 12451 RVA: 0x000FCEC0 File Offset: 0x000FB0C0
	public static void SetOverride(Texture front = null, Texture back = null, Texture left = null, Texture right = null, Texture top = null, Texture bottom = null)
	{
		CVRCompositor compositor = OpenVR.Compositor;
		if (compositor != null)
		{
			Texture[] array = new Texture[]
			{
				front,
				back,
				left,
				right,
				top,
				bottom
			};
			Texture_t[] array2 = new Texture_t[6];
			for (int i = 0; i < 6; i++)
			{
				array2[i].handle = ((!(array[i] != null)) ? IntPtr.Zero : array[i].GetNativeTexturePtr());
				array2[i].eType = SteamVR.instance.textureType;
				array2[i].eColorSpace = EColorSpace.Auto;
			}
			EVRCompositorError evrcompositorError = compositor.SetSkyboxOverride(array2);
			if (evrcompositorError != EVRCompositorError.None)
			{
				GlobalData.Debug_LogError("Failed to set skybox override with error: " + evrcompositorError);
				if (evrcompositorError == EVRCompositorError.TextureIsOnWrongDevice)
				{
					GlobalData.Debug_Log("Set your graphics driver to use the same video card as the headset is plugged into for Unity.");
				}
				else if (evrcompositorError == EVRCompositorError.TextureUsesUnsupportedFormat)
				{
					GlobalData.Debug_Log("Ensure skybox textures are not compressed and have no mipmaps.");
				}
			}
		}
	}

	// Token: 0x060030A4 RID: 12452 RVA: 0x000FCFB4 File Offset: 0x000FB1B4
	public static void ClearOverride()
	{
		CVRCompositor compositor = OpenVR.Compositor;
		if (compositor != null)
		{
			compositor.ClearSkyboxOverride();
		}
	}

	// Token: 0x060030A5 RID: 12453 RVA: 0x000FCFD4 File Offset: 0x000FB1D4
	private void OnEnable()
	{
		SteamVR_Skybox.SetOverride(this.front, this.back, this.left, this.right, this.top, this.bottom);
	}

	// Token: 0x060030A6 RID: 12454 RVA: 0x000FD000 File Offset: 0x000FB200
	private void OnDisable()
	{
		SteamVR_Skybox.ClearOverride();
	}

	// Token: 0x04003099 RID: 12441
	public Texture front;

	// Token: 0x0400309A RID: 12442
	public Texture back;

	// Token: 0x0400309B RID: 12443
	public Texture left;

	// Token: 0x0400309C RID: 12444
	public Texture right;

	// Token: 0x0400309D RID: 12445
	public Texture top;

	// Token: 0x0400309E RID: 12446
	public Texture bottom;

	// Token: 0x0400309F RID: 12447
	public SteamVR_Skybox.CellSize StereoCellSize = SteamVR_Skybox.CellSize.x32;

	// Token: 0x040030A0 RID: 12448
	public float StereoIpdMm = 64f;

	// Token: 0x02000839 RID: 2105
	public enum CellSize
	{
		// Token: 0x040030A2 RID: 12450
		x1024,
		// Token: 0x040030A3 RID: 12451
		x64,
		// Token: 0x040030A4 RID: 12452
		x32,
		// Token: 0x040030A5 RID: 12453
		x16,
		// Token: 0x040030A6 RID: 12454
		x8
	}
}
